﻿using System;
using System.Collections.Generic;
using System.Linq;
using Seagull.Configuration;
using Seagull.DAL;

namespace Seagull.Shell.Views
{
    internal class RealtimeController : ChannelFrameSetProvider
    {
        public RealtimeController()
        {
            Channels = new List<byte>(Config.Instance.UIConfig.MaxChannelSelection);
        }

        public List<byte> Channels { get; set; }

        /// <summary>
        /// 刷新选中通道的实时数据
        /// </summary>
        public void Update()
        {
            OnNewFrames(new NewFramesEventArgs
            {
                ChannelFrames = Channels
                    .Select(p => Tuple.Create(p, RealtimeFrameSetSource.Instance.FrameSets[p]))
                    .Where(t => t.Item2 != null)
                    .ToArray()
            });
        }
    }
}